<script setup>
import Nodes from "../../ProcessNodes.js";
import { ref} from "vue";
const nodeList = Object.keys(Nodes)
    .filter(v => Nodes[v].name).map(v => {
      return {
        type: v,
        ...Nodes[v]
      }
    })
// defineEmits(['insertNode'])
const popover=ref()
const emit = defineEmits()
function insertNode(type){
  popover.value.hide()
  emit('insertNode',type)
}
</script>

<template>
  <el-popover width="320" ref="popover" itle="添加流程节点" placement="right-start" trigger="click">
    <template #reference>
      <img src="../../../../../../../../../assets/node_add.png" alt="" class="node_add" >
    </template>
    <div class="w-node-options d_f j_c_s_b a_i_c">
      <div v-for="(node,index) in nodeList" :key="node.type" @click="insertNode(node.type) ">
        <div class="share d_f j_c_c a_i_c">
            <img src="../../../../../../../../../assets/moreFilled.png" alt="" class="svg" v-if="index == 1">
            <img src="../../../../../../../../../assets/share.png" alt="" class="svg" v-if="index == 0">
            <img src="../../../../../../../../../assets/task.png" alt="" class="svg" v-if="index == 2">
            <img src="../../../../../../../../../assets/condition.png" alt="" class="svg" v-if="index == 3">
            <img src="../../../../../../../../../assets/delay.png" alt="" class="svg" v-if="index == 4">
          </div>
        {{node.name}}
      </div>
    </div>
  </el-popover>
</template>

<style scoped>
.node_add {
  width: 30px;
  height: 30px;
  z-index: 9999;
}
.share{
  font-size: 25px;
        width: 35px;
        height: 35px;
        border: 1px solid #dedfdf;
        border-radius: 16px;
        margin-right: 10px;
}
.svg {
 width: 18px;
 height: 18px;
 
}
.w-node-options {
  display: flex;
  flex-wrap: wrap;

  i {
    padding: 3px;
    margin-right: 5px;
    border-radius: 10px;
    border: 1px solid #DEDFDF;
  }

  & > div {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 15px;
    background: #F8F9F9;
    margin: 5px;
    width: 110px;

    &:hover {
      box-shadow: 0 0 5px 0 #E3E3E3;
    }
  }
}
</style>
